package cn.mysocketnet.a05tcpdemo1;

import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) {
        //TCP协议，接收数据

        //1.创建对象ServerSocker
        try(ServerSocket ss = new ServerSocket(10000)){
            //2.监听客户端的链接
            Socket socket = ss.accept();
            //3.从连接通道中获取输入流读取数据
            InputStream is = socket.getInputStream();
            int len;
            byte[] b = new byte[1024];
            while ((len = is.read(b)) != -1){
                System.out.println(new String(b,0,len));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
